#include <iostream>
#include <fstream>
#include <string>
#include "minio.h"

#define MINIO_ENDPOINT "play.min.io:9000"
#define MINIO_ACCESS_KEY "Q3AM3UQ867SPQQA43P2F"
#define MINIO_SECRET_KEY "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
#define MINIO_BUCKET_NAME "test-bucket"

using namespace std;

int main()
{
    minio::MinioClient minioClient(MINIO_ENDPOINT, MINIO_ACCESS_KEY, MINIO_SECRET_KEY);
    if (minioClient.bucket_exists(MINIO_BUCKET_NAME))
    {
        minio::headers_t headers;
        minio::response_str_stream responseStream;
        minioClient.get_object(MINIO_BUCKET_NAME, "CAN_data.txt", responseStream, headers);  //传输文件名称，将文件内容传输到responseStream变量中
        cout << responseStream.str() << endl;  // 输出文件内容
    }
    else
    {
        cout << "Bucket does not exist!" << endl;   
    }
    return 0;
}
